package com.demo.controller;

import com.demo.Service.StockService;
import com.demo.Service.accountService;
import com.demo.rabbitmq.SmsProducer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/stock")
@RefreshScope //自动刷新配置
public class stockController {

    @Value("${config.info}")
    String name;

    @Resource
    private SmsProducer smsProducer;



    @Resource
    private accountService accountService;

    @Resource
    private StockService stockService;
//
//    @GetMapping("/test")
//    public List test(String info){
//        return  seataMapper.getlist();
//    }

    @GetMapping("/test")
    public Object test(String info){
        return  accountService.insert_account();
    }

    @GetMapping("/send1")
    public String sendDelayedMessage(@RequestParam("body") String body,
                                     @RequestParam("seconds") Integer seconds) {
        return  smsProducer.sendDelayedMessage(body,seconds);
    }

    @RequestMapping(path = "/deduct")
    public Boolean deduct(String commodityCode, Integer count) {
        stockService.deduct(commodityCode, count);
        return true;
    }
}
